<h1>标准库函数 - time</h1>


  <p>原型：extern int time(struct tm *pTime);</p>
              
  <p>用法：#include &lt;system.h></p>
  
  <p>功能：取得系统时间</p>
  
  <p>说明：结构tm在system.h中定义</p>
  <pre><code class="language-c">

        struct tm
        {
          int  hsec;    /* Half Seconds.  [0-119] */
          int  sec;     /* Seconds        [0-59]  */
          int  min;     /* Minutes        [0-59]  */
          int  hour;    /* Hours          [0-23]  */
          int  day;     /* Day            [0-30]  */
          int  wday;    /* Day of Week    [0-6]   */
          int  mon;     /* Month          [0-11]  */
          int  year;    /* Year - 1881            */
        };
    </code></pre>

        
    
  举例：<pre><code class="language-c">

      // timec
      
      #include &lt;system.h>
      #define CPR 14

      main()
      {
        struct tm t1,t2;
        char wday[][3]={"日","一","二","三","四","五","六"};
        
        clrscr();
        textmode(0xE0);
        time(&t2);
        while(!kbhit())
        {
          noidle();
          time(&t1);
          if(t1.hsec==t2.hsec) continue;
          t2.hsec=t1.hsec;
          move(1,1);
          printf("%d年%2d月%2d日",t1.year+1881,t1.mon+1,t1.day+1);
          move(2,(CPR-8)/2+1);
          printf("%d:%d%d:%d%d",t1.hour,t1.min/10,t1.min%10,t1.sec/10,t1.sec%10);
          move(3,2);
          printf("今天是星期%s",wday[t1.wday]);
        }
        
        return 0;
      }
      
  </code></pre>相关函数：无

